{include file="public/header" /}
<body>
<div class="layui-tab layui-tab-brief main-tab-container">
    <ul class="layui-tab-title main-tab-title">
      <a href="{:url('article/index_cate')}"><li class="layui-this">栏目列表</li></a>
      <a href="{:url('article/add_cate')}"><li>添加栏目</li></a>
      <div class="main-tab-item">栏目管理</div>
    </ul>
    <div class="layui-tab-content">
      <div class="layui-tab-item layui-show">
      <form class="layui-form" name="paixu" method="post" onsubmit="return false;">

            <table class="list-table">
              <thead>
                <tr>
                  <th style="width:40px">排序</th>
                  <th>ID</th>
                  <th>栏目名称</th>
                  <th>创建时间</th>
                  <th>修改时间</th>
                  <th>状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              
                <tbody>
                  {volist name="cateObj" id="vo"}
                  <tr>
                    <td><input name="{$vo.cate_id}" type="text" value="{$vo.sort}" lay-verify="number" class="layui-input"></td>
                    <td>{$vo.cate_id}</td>
                    <td>
                      {$vo.name}
                    </td>
                    <td>{$vo.create_tim|default=time()|date='Y-m-d',###}</td>
                    <td>{$vo.update_tim|default=time()|date='Y-m-d',###}</td>
                    {if condition="$vo['status'] == 1"}
                    <td><span style="background-color: #23c6c8;color: #FFF;font-size: 10px;font-weight: 500;padding: 3px 8px;border-radius: .25em;">开启</span></td>
                    {else/}
                    <td><span style="background-color: #ed5565;;color: #FFF;font-size: 10px;font-weight: 500;padding: 3px 8px;border-radius: .25em;">禁用</span></td>
                    {/if}
                    <td style="text-align: center;">
                      <a href="{:url('edit_cate',array('cate_id'=>$vo['cate_id']))}
" class="layui-btn layui-btn-small" title="编辑"><i class="layui-icon"></i></a>
                      <a class="layui-btn layui-btn-small layui-btn-danger del_btn" category-id="1" title="删除" id="{$vo.cate_id}"><i class="layui-icon"></i></a>
                    </td>
                  </tr>
                  {/volist}
                </tbody>
                <thead>
                  <tr >
                    <th colspan="7" ><button class="layui-btn" lay-submit="" lay-filter="sort" style="float:left;" id="sbtn">排序</div></th>
                  </tr>

                </thead>
              
            </table>

      </form>
      </div>
    </div>
</div>
<script type="text/javascript">
$(function(){
        //添加操作
        $("#sbtn").click(function(){    
            $.ajax({
              url: "{:url('article/sort')}",
              data: $("form").serialize(),
              type: "POST",
              datatype:"json",
              success: function( result ) {
                  layer.open({
                      title: '信息'
                      ,content: '更新成功！'
                  });
              }
            });
        });
        //删除操作
        $(".del_btn").click(function(){
            var $this = $(this)
            var id=$this.attr('id');
            $.ajax({
              url: "{:url('article/del_cate')}",
              data: {'id':id},
              type: "POST",
              datatype:"json",
              success: function( result ) {
                  $this.parents('tr').remove();
                  layer.open({
                      title: '信息'
                      ,content: '删除成功！'
                  });
              }
            });
        });
        //状态
        $("#zzz").click(function(){
        $.ajax({
            url: "{:url('article/status')}",
            data: $("form").serialize(),
            type: "POST",
            datatype:"json",
            success: function( result ) {
                layer.open({
                    title: '信息'
                    ,content: '设置成功！'
                });
            }
        });
    });

    });

layui.use(['element', 'layer', 'form'], function(){
  var element = layui.element()
  ,jq = layui.jquery
  ,form = layui.form()
  ,laypage = layui.laypage;

})
</script>
</body>
</html>